package com.arpa.wms.mapper;

import com.arpa.wms.domain.dto.InboundDTO;
import com.arpa.wms.domain.entity.Inbound;
import com.arpa.wms.domain.vo.InboundImportVO;
import com.arpa.wms.domain.vo.InboundItemImportVO;
import com.arpa.wms.domain.vo.InboundItemVO;
import com.arpa.wms.domain.vo.InboundVO;
import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 入库单 Mapper 接口
 * </p>
 *
 * @author LEO
 * @since 2020-08-04
 */
public interface InboundMapper extends BaseMapper<Inbound> {

    /**
     * 查询列表
     * @param inboundDTO
     * @return
     */
    List<InboundVO> queryList(InboundDTO inboundDTO);

    /**
     * 查询合计,包含总数
     * @param sql
     * @return
     */
    InboundVO queryListSum(@Param("sql") String sql);

    /**
     * 查询合计,包含总数
     * @param inboundDTO
     * @return
     */
    InboundVO queryListTotal(InboundDTO inboundDTO);


    /**
     * 一周内所有仓库的入库数量
     * @return
     */
    List<Map<String,Object>> inboundCount(List<String> warehouseCodes,List<String> shipmentCodes,String fdt,String groupCode);

    /**
     * 执行原生sql
     * @param sql
     */
    void execSql(@Param("sql") String sql);

    /**
     * 入库订单数量统计 Visual
     * @return
     */
    @SqlParser(filter = true)
    @Select("SELECT count(a.code) visual " +
            "FROM wms_inbound a " +
            "WHERE " +
            "a.type = #{type} AND a.is_deleted = 0 AND a.status = #{status}  AND left(a.gmt_created, 10) =  left(#{time}, 10)"
            )
    String inboundQuantityTrend(String type, String time, String status);


    List<InboundImportVO> importInbound(InboundDTO inboundDTO);

    List<InboundItemImportVO> importItemInbound(InboundDTO inboundDTO);

    /**
     * 查询导入单合计,包含总数
     * @param inboundDTO
     * @return
     */
    InboundImportVO importInboundSum(InboundDTO inboundDTO);


}
